<?php

declare(strict_types=1);

namespace App\Controller;

use Hyperf\Di\Annotation\Inject;
use Hyperf\WebSocketClient\ClientFactory;
use Hyperf\HttpServer\Annotation\AutoController;

use Hyperf\Nacos\Application;
use Hyperf\Nacos\Config;
use Hyperf\Codec\Json;

use Hyperf\Config\Annotation\Value;

use App\Controller\BaseController;

#[AutoController]
class IndexController extends BaseController
{
	#[Inject]
	protected ClientFactory $clientFactory;

	#[Value("nacos")]
	private $configValue;

	public function index()
	{
		//	   $NACOS_USERNAME = constant('NACOS_USERNAME');
		//	   var_dump($NACOS_USERNAME);
		//	   $NACOS_PASSWORD = constant('NACOS_PASSWORD');
		//	   var_dump($NACOS_PASSWORD);

		//      $NACOS_USERNAME = getenv('NACOS_USERNAME');
		//	   var_dump($NACOS_USERNAME);
		//	   $NACOS_PASSWORD = getenv('NACOS_PASSWORD');
		//	   var_dump($NACOS_PASSWORD);
		//	   $nacosInfo = $this->getNacos('appidAndAppsecret','DEFAULT_GROUP');
		//	   var_dump($nacosInfo);
		return;
		$application = new Application(new Config($this->configValue));
		$response = $application->config->get('requestUrl', 'DEFAULT_GROUP');
		$result = Json::decode((string) $response->getBody());
		var_dump($result);
		return;

		return "hello123";
		$host = '127.0.0.1:9502';
		$autoClose = false;
		$client = $this->clientFactory->create($host, $autoClose);
		$res = $client->push('你好哈哈哈');
		while (true) {
			$msg = $client->recv(2);
			if (!$msg) {
				break;
			}
			var_dump("+++++++++++");
			var_dump($msg);
			var_dump("-----------");
		}
	}
}
